<template>
  <div>
    <h3>aaaaaaaa</h3>
    
    
    <button @click="tobpage(12)">跳页到b</button>
    <button @click="postJack()">post</button>
        <button @click="getJack()">getJack</button>
        <input type="text" v-model="spoken">
    <button @click="getRequestQuery()">getRequest</button>
     <button @click="shopg()">shopg</button>
    <img :src="imgurl" style="with:200px;height:200px" alt="">
    <span>vuex中的数据：{{count}}</span><button @click="addstate()">addstate</button>
  </div>
</template>

<script>
import request from '../request/index.js'
import {request2} from '../request/index.js'
export default {
  data() {
    return {
        query:{
            name:'zhangsan',
            age:'123'
        },
        spoken:'',
        imgurl:'',
        count:0
    };
  },
  methods: {
    tobpage(m) {
      this.$router.push(`/b`);
    },
    async postJack(){
      const res=await this.$axios.post("https://autumnfish.cn/api/user/reg",{username: "yushw4324reuicai"})
      console.log(res)
    },
    getJack(){
       this.$axios.get("http://www.liulongbin.top:3006/api/robot",{params:{spoken:this.spoken}})
       .then(res=>{
         console.log(res)
       })
    },
    async getRequestQuery(){
     console.log(1)
     let obj={
       querystring:'主文明',
       pageSize:10,
       pageNum:4
     }
     let reg={
       username:'于水才',
       gendar:0,
       phone:122212,
       pwd:'123',
       imgurl:'jjjd/ddl'
     }
     const {data:res}= await request({url:"/users/logincheck",method:"post",data:{account:'admin',pwd:'admin'} })
     //this.imgurl=res.table[0].url
     console.log(res)
    },
    async login(){
       const {data:res}= await request({url:"/users/logincheck",method:"post",data:{account:'admin',pwd:'admin'} })
       console.log(res)
       //window.sessionStorage.setItem('token', res.token)
    },
    async shopg(){
      let token=window.sessionStorage.getItem('token')//相当于session
      const {data:res}= await request({url:"/shopcar/query",method:"post",data:{uid:540,token:token} })
       console.log(res)
    },
    addstate(){
     this.$store.commit("addstate",10)
     //this.count=this.$store.state.count
        //console.log(this.$store.getters.getStudentByAge(10)) 
     //this.$store.dispatch('addAsyncAction','211212').then(res=>{
       //console.log(res)
     //})
    }
  },
  created(){
    this.login()
    this.count=this.$store.state.count
  },
  
};
</script>
<style scoped>
/* @import url(); 引入css类 */
</style>